<!doctype html>
<%@ taglib prefix="s" uri="/struts-tags"%>
<html lang="en" class="no-js">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

        <title>Business Lookup</title>
        <meta name="description" content="">
        <meta name="author" content="">
        <!-- Load css and javascript -->
        <link href="css/main.css" rel="stylesheet" type="text/css">
        <script src="js/jquery-latest.js"></script>
        <script src="js/index.js"></script>        
        <script src="js/jquery.tablesorter.js"></script>

        <script type="text/javascript">
            var busID = null;
            
            function post_value() {
                try{
                    //get values from table 
                    var radio = $("input[name=radioBusiness]:checked", "#table_form");
                    var row = radio.parent().parent();
                    var businessName = row.children()[1].innerHTML;
                    var sicCode = row.children()[2].innerHTML;
                    //pass values to parent windown 
                    window.opener.document.getElementById("lu.typeOfBusinessID").value = busID;
                    window.opener.document.getElementById("lu.businessName").value = businessName;
                    window.opener.document.getElementById("lu.sicCode").value = sicCode;
                    self.close();

                } catch(er) {
                    alert("Please select a business");
                }
            }
        
            function none_value() {
                try {        
                	window.opener.document.getElementById("lu.typeOfBusinessID").value = "";
                    window.opener.document.getElementById("lu.businessName").value = "";
                    window.opener.document.getElementById("lu.sicCode").value = "";
                    self.close();
                    
                } catch (err) {
                    alert(err.message);
                }
            }
            
            function clear_value() {
                try {                                        
                    document.getElementsByName("business.businessName")[0].value = "" ;
                    document.getElementsByName("business.sicCode")[0].value = "" ;        
                    
                } catch (err) {
                    alert(err.message);
                }
            }
            
            try {
                $(document).ready(function() 
                { 
                    $("#tablepaging").tablesorter(); 
                }
            );
            } catch(ex)
            {
                alert(ex.message);
            }
    
            
        </script>

        <!-- Favicon -->
        <link rel="shortcut icon" type="image/x-icon" href="favicon.ico">
        <link rel="icon" type="image/png" href="favicon-large.png">      

    </head>

    <body>

        <!-- Header -->

        <!-- Status bar -->

        <!-- End status bar -->

        <div id="header-shadow"></div>
        <!-- End header -->

        <!-- Always visible control bar -->
        <div id="control-bar" class="grey-bg clearfix">
            <div class="container_12"></div>
        </div>
        <!-- End control bar -->

        <!-- Content -->
        <article class="container_12">

            <section class="grid_88">
                <s:actionerror/>
                <div class="block-border">
                    <form class="block-content form" id="table_form" action="bus_lookup.action" method="get">
                        <h1>Business Lookup</h1>

                        <div class="block-controls">

                            <s:actionerror/>
                            <fieldset class="grey-bg">
                                <div    class="float-left gutter-right"
                                        style="margin-right: 100px;">
                                    <div style="color: #666; font-weight: bold; line-height: 30px; float: left; padding-right: 10px;">
                                        Business Name:</div>
                                        <s:textfield name="business.businessName" cssClass="full-width"
                                                     style="width: 300px !important;" />                                             
                                </div>
                                <div class="float-left gutter-right">
                                    <div
                                        style="color: #666; font-weight: bold; line-height: 30px; float: left; padding-right: 10px;">
                                        SIC Code:</div>
                                        <s:textfield name="business.sicCode" cssClass="full-width"
                                                     style="width: 90px !important;" />
                                </div>
                            </fieldset>                            


                            <div class="clear"></div>
                            <div>

                                <ul class="keywords">
                                    <li>
                                        <s:a href="" onclick="document.forms[0].submit()" style="cursor:pointer">Search</s:a>
                                       
                                    </li>
                                    <li><a href="javascript:none_value()"> None </a>
                                    </li>
                                    <li><a href="javascript:clear_value()"> Clear </a>        
                                </ul>                                
                            </div>
                        </div>


                        <div class="no-margin">
                            <table class="table tablesorter" id="tablepaging" cellspacing="0"
                                   width="100%">
                                <thead>
                                    <tr>
                                        <th></th>                                        
                                        <th scope="col">Business Name</th>
                                        <th scope="col">SIC Code</th>
                                    </tr>
                                </thead>
                                <tbody>    
                                    <s:iterator value="list" var="item">
                                        <tr>
                                            <td scope="row" class="table-check-cell">
                                                <input
                                                    type="radio" name="radioBusiness" id="radioBusiness"
                                                    value="${item.typeOfBusinessID}" onchange="busID = this.value;">
                                            </td>
                                            <td>${item.businessName}</td>
                                            <td>${item.sicCode}</td>
                                        </tr>
                                    </s:iterator>
                                </tbody>
                            </table>
                        </div>
                        <div class="block-footer" id="pageNavPosition">
                            <script type="text/javascript">
                                var pager = new Pager(
                                'tablepaging', 15);
                                pager.init();
                                pager.showPageNav('pager',
                                'pageNavPosition');
                                pager.showPage(1);
                            </script>
                        </div>
                        <div>           
                            <ul class="keywords">
                                <li><a href="javascript:post_value()"> Select </a>
                                </li>
                                <li><a href="" onclick="self.close();"> Close </a>
                                </li>
                            </ul>
                        </div>
                    </form> 
                </div>
            </section>
            <div class="clear"></div>
        </article>                          
    </body>
</html>